home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1991 …esperately Seeking Seven / Desperately Seeking Seven.2mg / Dev.CD.8 / Essentials / Tools / DTS.Samples / SC02BusyBox / BusyBox.p / UWindow.p < prev   
Encoding:
Text File  |  1990-05-25  |  4.3 KB  |  174 lines  |  [04] ASCII Text (0x0000)

  1. {**********************************************************************
  2. {*
  3. {* BusyBox uWindow -- Version 3.0  (interface)
  4. {*
  5. {* Copyright (c)
  6. {* Apple Computer, Inc.  1986-1989
  7. {* All Rights Reserved.
  8. {*
  9. {* Developer Technical Support Apple II Sample Code
  10. {*
  11. {* This file contains the interface to the code which implements  
  12. {* windows in the busybox program.
  13. {*
  14. {**********************************************************************}
  15.  
  16. UNIT uWindow;
  17.  
  18. INTERFACE
  19.  
  20. USES
  21.  
  22.        types,
  23.        GSOS,
  24.        locator,
  25.        quickdraw,
  26.        fonts,
  27.        MEMORY,
  28.        intMath,
  29.        events,
  30.        controls,
  31.        windows,
  32.        lineedit,
  33.        dialogs,
  34.        menus,
  35.        DESK,
  36.        STDFILE,
  37.        resources,
  38.        TextEdit,
  39.        
  40.        
  41.        uGlobals,
  42.        uUtils;
  43.  
  44. var
  45.     TheMainWindow,
  46.     ButtonsWindow,
  47.     StatTextWindow,
  48.     LineEditWindow,
  49.     PicturesWindow,
  50.     PopUpsWindow,
  51.     TextEditWindow,
  52.     ListsWindow         : GrafPortPtr;
  53.  
  54. procedure SetUpWindows;            {Initialize variables for stacking windows}
  55. procedure DrawThisWindow;
  56. procedure DoCloseTop;
  57. procedure OpenThisWindow   (CtlID : integer);
  58.  
  59.  
  60.  
  61.  
  62. IMPLEMENTATION
  63.  
  64. {$R-}
  65.  
  66. const   MainWindowID = $2000;
  67.  
  68.  
  69. {**********************************************************************}
  70. {
  71. { DrawThisWindow
  72. {
  73. { This routine draws the contents of all the windows.
  74. {
  75. {*
  76. {* Warning:  Do not make any calls that use the libraies or use
  77. {* short addressing without setting the dbr to ~globals.
  78. {*
  79. {**********************************************************************}
  80. procedure DrawThisWindow;
  81.     begin
  82.         DrawControls(GetPort);
  83.     END;
  84.     
  85. {**********************************************************************}
  86. {
  87. { DoCloseTop
  88. {
  89. { This routine closes the topmost window.  We do a little work to
  90. { prevent the main window from being closed.
  91. {
  92. {**********************************************************************}
  93. procedure DoCloseTop;
  94.     var
  95.         k : integer;
  96.         TempWin : GrafPortPtr;
  97.         
  98.     begin
  99.         { Get the front window into a local variable }
  100.         TempWin := FrontWindow;
  101.         
  102.         { start the count at 1 since we never close the main window }
  103.         k := 1;
  104.         
  105.         { Find the window entry, close the window, and zero the entry }
  106.         repeat
  107.         
  108.             if TempWin = WindowList[k] then
  109.                 begin
  110.                     CloseWindow(TempWin);
  111.                     WindowList[k] := NIL;
  112.                     k := NumWindows;
  113.                 end
  114.             else
  115.                 k := k+1;
  116.         until k >= NumWindows;      
  117.     end;
  118.     
  119. {****************************************************************************}
  120. {
  121. { OpenThisWindow
  122. {
  123. { This routine either opens the specified window or brings it to the top
  124. { if it is already open.
  125. {
  126. { If it is not open, we open it with NewWindow2 invisibly, adjust the window's
  127. { location and then show and select the window.
  128. {
  129. { ID values for controls in the main window are assumed here to be from 1..n
  130. {
  131. {****************************************************************************}
  132. procedure OpenThisWindow   (CtlID : integer);
  133.     begin
  134.         if WindowList[CtlID] = NIL then
  135.             begin
  136.                 WindowList[CtlID] := NewWindow2(NIL,0,@DrawThisWindow,NIL,2,
  137.                          Ref(POINTER(MainWindowID+CtlID)),rWindParam1);
  138.                 if CtlID < Prog1ID then 
  139.                     begin
  140.                         MoveWindow (50+8*StaggerCount,50+8*StaggerCount,WindowList[CtlID]);
  141.                         StaggerCount := StaggerCount+1;
  142.                     end;
  143.                 ShowWindow(WindowList[CtlID]);
  144.                 SelectWindow(WindowList[CtlID]);                
  145.             end
  146.         else SelectWindow(WindowList[CtlID]);
  147.     end;
  148.     
  149.     
  150. {*****************************************************************************}
  151. {
  152. { SetUpWindows
  153. {
  154. { Sets up WindowList record for use through out the program.
  155. {
  156. {*****************************************************************************}
  157. procedure SetUpWindows;
  158.     var
  159.         k : integer;
  160.         
  161.     begin   {of SetUpWindows}
  162.         { Zero out the entries in the window list. }
  163.         for k := 0 to NumWindows-1 do WindowList[k] := NIL;
  164.         
  165.         { Open the main window }
  166.         WindowList[0] := NewWindow2(NIL,0,@DrawThisWindow,NIL,2,ref(MainWindowID),
  167.                                rWindParam1);
  168.     end;    {of SetUpWindows}
  169.     
  170.  
  171.  
  172.  
  173. END.
  174.